<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改转写事件')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: summernote-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-transfer-edit" th:object="${voiceTransfer}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">事件ID：</label>
                <div class="col-sm-8">
                    <input name="transferId" th:field="*{transferId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">应用ID：</label>
                <div class="col-sm-8">
                    <input name="productId" th:field="*{productId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">用户ID：</label>
                <div class="col-sm-8">
                    <input name="userId" th:field="*{userId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">设备ID：</label>
                <div class="col-sm-8">
                    <input name="deviceId" th:field="*{deviceId}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">语种：</label>
                <div class="col-sm-8">
                    <input name="transferLanguages" th:field="*{transferLanguages}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件名称：</label>
                <div class="col-sm-8">
                    <input name="transferName" th:field="*{transferName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件格式：</label>
                <div class="col-sm-8">
                    <input name="transferFormat" th:field="*{transferFormat}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件大小：</label>
                <div class="col-sm-8">
                    <input name="transferSize" th:field="*{transferSize}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">文件路径：</label>
                <div class="col-sm-8">
                    <input name="transferPath" th:field="*{transferPath}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">录音时长：</label>
                <div class="col-sm-8">
                    <input name="transferDuration" th:field="*{transferDuration}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">采样率：</label>
                <div class="col-sm-8">
                    <input name="transferSampling" th:field="*{transferSampling}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">Bit位：</label>
                <div class="col-sm-8">
                    <input name="transferBit" th:field="*{transferBit}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">合作方ID(百度taskID，讯飞OrderID)：</label>
                <div class="col-sm-8">
                    <input name="providerId" th:field="*{providerId}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">预计转写时长:讯飞有返回预计时长，百度的可根据讯飞的计算方法来计算一个，便于返回告知用户。：</label>
                <div class="col-sm-8">
                    <input name="estimatedTime" th:field="*{estimatedTime}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">转写API[暂时为百度或者讯飞]：</label>
                <div class="col-sm-8">
                    <input name="transferApi" th:field="*{transferApi}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">结果：</label>
                <div class="col-sm-8">
                    <input name="resultCode" th:field="*{resultCode}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">获得结果的内容：</label>
                <div class="col-sm-8">
                    <input type="hidden" class="form-control" th:field="*{resultContent}">
                    <div class="summernote" id="resultContent"></div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">获得结果的时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="resultTime" th:value="${#dates.format(voiceTransfer.resultTime, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">实际时长：</label>
                <div class="col-sm-8">
                    <input name="realDuration" th:field="*{realDuration}" class="form-control" type="text">
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: summernote-js" />
    <script th:inline="javascript">
        var prefix = ctx + "product/transfer";
        $("#form-transfer-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/saveOrUpdate", $('#form-transfer-edit').serialize());
            }
        }

        $("input[name='resultTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $(function() {
            $('.summernote').each(function(i) {
                $('#' + this.id).summernote({
                    lang: 'zh-CN',
                    dialogsInBody: true,
                    callbacks: {
                        onChange: function(contents, $edittable) {
                            $("input[name='" + this.id + "']").val(contents);
                        },
                        onImageUpload: function(files) {
                            var obj = this;
                            var data = new FormData();
                            data.append("file", files[0]);
                            $.ajax({
                                type: "post",
                                url: ctx + "common/upload",
                                data: data,
                                cache: false,
                                contentType: false,
                                processData: false,
                                dataType: 'json',
                                success: function(result) {
                                    if (result.code == web_status.SUCCESS) {
                                        $('#' + obj.id).summernote('insertImage', result.url);
                                    } else {
                                        $.modal.alertError(result.msg);
                                    }
                                },
                                error: function(error) {
                                    $.modal.alertWarning("图片上传失败。");
                                }
                            });
                        }
                    }
                });
                var content = $("input[name='" + this.id + "']").val();
                $('#' + this.id).summernote('code', content);
            })
        });
    </script>
</body>
</html>